package com.seaengine.util
{
	import flash.utils.Dictionary;

	/**
	 * get some random stuff
	 * @author 曹鹏
	 *
	 */
	public class RandomUtil
	{
		public static function getAnItem(collection:*):*
		{
			if (collection is Dictionary)
				return getAnItemInDictionary(collection);
			else if (true)
				return null; /**to be continued*/

			return null;
		}

		public static function getAnItemInDictionary(dict:*):*
		{
			var length:int = 1;
			while (length) /**也许dungeonZoneList里没有元素*/
			{
				length = 0;
				for each (var vo:* in dict)
				{
					length++;
					if (getBoolean())
						return vo;
				}
			}
			return null;
		}


		public static function getBoolean():Boolean
		{
			return Math.random() < .5;
		}
		
		public static function getFirstItemInDict(dict:Dictionary):*
		{
			for each (var vo:* in dict)
				return vo;
			return null;
		}
	}
}
